package com.fd.service.impl;

import com.fd.dao.ProductDAO;
import com.fd.dao.impl.PorductDAOImpl;
import com.fd.pojo.Products;
import com.fd.service.CommodityService;

import java.util.List;

public class CommodityServiceImpl implements CommodityService {
    private ProductDAO productDAO=new PorductDAOImpl();

    /**
     * 查询数据库
     * @return
     */
    public List<Products>  selectAll() {
        return productDAO.findProducts();
    }

    /**
     * 添加商品
     * @param pid
     * @param cid
     * @param pname
     * @param price
     * @return
     */
    public boolean insertGoods(String pid,String cid, String pname, double price) {
        return productDAO.insertGoods(pid,cid,pname,price);
    }

    /**
     * 根据id删除商品
     * @param pid
     * @return
     */
    public boolean deleteGoodsByID(String pid) {
        return productDAO.deleteGoodsById(pid);
    }

    /**
     *修改商品
     */
    public boolean modifyGood(Products products) {
        return productDAO.updateGoods(products);
    }
}
